package com.czl.websocket.controller.api;

import com.czl.common.mvc.RestApiResult;
import com.czl.websocket.server.ChatMatchService;
import com.czl.websocket.server.WebSockeManger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author 石雷
 * shilei1@jiayuan.com
 * 2021/1/22/022 14:58
 */
@RestController
@RequestMapping("/online")
public class OnlineApi {

    /**
     * 查询在线人数
     * @return
     */
    @RequestMapping("/total")
    public RestApiResult total(){
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("count",WebSockeManger.getWebSocketList().size());
        return RestApiResult.create(RestApiResult.RetCode.SUCCESS.getValue(),RestApiResult.RetCode.SUCCESS.getInfo(),objectObjectHashMap);
    }

}
